﻿




using System.Linq;
using Hotpot.Infrastructure;
using Hotpot.Models;

namespace Hotpot.Extensions
{
    public static class IQueryableExtensions
    {
        public static IPageOfItems<T> GetPage<T>(this IQueryable<T> query, PagingInfo pagingInfo)
        {
            return new PageOfItems<T>(query.Skip(pagingInfo.Index * pagingInfo.Size).Take(pagingInfo.Size), pagingInfo.Index, pagingInfo.Size, query.Count());
        }
    }
}